package campus.controller;

import campus.model.*;
import campus.service.AccountService;
import campus.service.CashFlowService;
import campus.util.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.text.SimpleDateFormat;
import java.util.List;

/**
     * @Author M
     * @name 报表控制层
     * @Date 15:24 2020/5/12
 **/
@RestController
@CrossOrigin
@RequestMapping("cashflow")
public class CashFlowController {
    @Autowired
    private CashFlowService cashFlowService;

    /**
         * @Author M
         * @name 现金流量列表
         * @Date 15:26 2020/5/12
     **/
    @RequestMapping(value = "/selectByExample",method = RequestMethod.POST)
    public List<CashFlow> selectByExample(@RequestBody CashFlow cashFlow) {
        if(cashFlow.getXmCdate() != null){
            SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            String s = format.format(cashFlow.getXmCdate());
            cashFlow.setxCdate(s);
        }
        List<CashFlow> cashFlows = cashFlowService.selectByExample(cashFlow);
        return cashFlows;
    }
    /**
         * @Author M
         * @name 财务概要信息
         * @Date 18:14 2020/5/12
     **/
    @RequestMapping(value = "/selectByAll",method = RequestMethod.POST)
    public List<Financial> selectByAll(@RequestBody Financial financial) {
        if(financial.getCwCdate() != null){
            SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            String s = format.format(financial.getCwCdate());
            financial.setcCdate(s);
        }
        List<Financial> financials = cashFlowService.selectByAll(financial);
        return financials;
    }
    
    /**
         * @Author M
         * @name 资产负债表
         * @Date 18:39 2020/5/12
     **/
    @RequestMapping(value = "/selectAll",method = RequestMethod.POST)
    public List<AssetsLiabilities> selectAll(@RequestBody AssetsLiabilities assetsLiabilities) {
        if(assetsLiabilities.getZcCdate() != null){
            SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            String s = format.format(assetsLiabilities.getZcCdate());
            assetsLiabilities.setzCdate(s);
        }
        List<AssetsLiabilities> assetsLiabilities1 = cashFlowService.selectAll(assetsLiabilities);
        return assetsLiabilities1;
    }

    /**
         * @Author M
         * @name 利润表
         * @Date 18:56 2020/5/12
     **/
    @RequestMapping(value = "/selectByAl",method = RequestMethod.POST)
    public List<Profits> selectByAl(@RequestBody Profits profits) {
        if(profits.getLzCdate() != null){
            SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            String s = format.format(profits.getLzCdate());
            profits.setlCdate(s);
        }
        List<Profits> profits1 = cashFlowService.selectByAl(profits);
        return profits1;
    }
}
